﻿''' <summary>
''' 状态
''' </summary>
Public Enum ResourceStatus
    ''' <summary>
    ''' 等待
    ''' </summary>
    Waiting
    ''' <summary>
    ''' 下载中
    ''' </summary>
    Downloading
    ''' <summary>
    ''' 下载完毕
    ''' </summary>
    Downloaded
    ''' <summary>
    ''' 出错
    ''' </summary>
    [Error]
    ''' <summary>
    ''' 不匹配
    ''' </summary>
    ''' <remarks></remarks>
    NotMatch
End Enum

Public Class ResourceStatusFormatter

    Shared Function EnumToString(status As ResourceStatus) As String
        Select Case status
            Case ResourceStatus.Downloaded
                Return "Downloaded"
            Case ResourceStatus.Downloading
                Return "Downloading"
            Case ResourceStatus.Error
                Return "Error"
            Case ResourceStatus.NotMatch
                Return "NotMatch"
            Case ResourceStatus.Waiting
                Return "Waiting"
            Case Else
                Return String.Empty
        End Select
    End Function

    Shared Function StringToEnum(str As String) As String
        If str.Equals("Downloaded") Then
            Return ResourceStatus.Downloaded
        ElseIf str.Equals("Downloading") Then
            Return ResourceStatus.Downloading
        ElseIf str.Equals("Error") Then
            Return ResourceStatus.Error
        ElseIf str.Equals("NotMatch") Then
            Return ResourceStatus.NotMatch
        ElseIf str.Equals("Waiting") Then
            Return ResourceStatus.Waiting
        Else
            Return ResourceStatus.Waiting
        End If
    End Function
End Class